package com.flash.materials.controller;

import com.flash.materials.domain.Materials;
import com.flash.materials.service.MaterialService;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.crypto.interfaces.PBEKey;
import java.util.List;

/**
* @description: TODO
* @author admin
* @date 2023/1/309:56
* @version 1.0
*/
@RequestMapping("mater")
@RestController
public class MateriaController {

    @Autowired
    MaterialService materialService;


    @GetMapping("getAll")
    public List<Materials> getAll(){
        Long userId = com.ruoyi.common.security.utils.SecurityUtils.getUserId();
        int intValue = userId.intValue();
        Integer a=(Integer)intValue;
        if(a.equals(1)){
            a=null;
        }
        List<Materials> all = materialService.getAll(a);
        return all;
    }

    @GetMapping("deleteById/{id}")
    public String deleteById(@PathVariable Integer id){
        String s = materialService.deleteById(id);
        return s;
    }

    @PostMapping("updateById")
    public String updateById(@RequestBody Materials materials){
        String s = materialService.updateById(materials);
        return s;
    }

    @PostMapping("save")
    public String save(@RequestBody Materials materials){
        String save = materialService.save(materials);
        return save;
    }

}
